/**
 * Created by Administrator on 2015/12/29.
 */
angular.module('maincontent.controller',[])
  .controller('mainContentCtrl',['$scope','$localstorage','mainContentService',function($scope,$localstorage,mainContentService){

    $scope.params={};
    $scope.params=mainContentService.getParams();
    $scope.visible=true; //初始
    $scope.$on('$ionicView.enter', function(event, data) {

      if("maincontent"==data.stateId) //主页面
      {
        if($localstorage.get("LOG_FLAG")=="1"){
          mainContentService.insertLog("主页面").then(function(data){
            //console.log("插入日志"+angular.toJson(data));
          },function(error){
            //console.log("插入日志失败，请联系管理员");
          });
        }

        
       if(!$localstorage.get("mac") )
       {
         $scope.visible=false; //如果没有配置过mac，则展示浮层
       }
       else
       {
         $scope.visible=true;//负责不展示浮层
       }
        $scope.DEPART_NAME=$localstorage.get("DEPART_NAME");
        $scope.STAFF_ID=$localstorage.get("STAFF_ID");//防止两次登录后工号不变

        mainContentService.get_BasicOrderInfo().then(
          function(data){
            if(data.respCode=="0"){
              $scope.params.orderCount=data.data.TOTAL_ORDER;
              $scope.params.orderFee=!data.data.TOTAL_FEE?"0":data.data.TOTAL_FEE;
            }

          },
          function(error){

          });

        mainContentService.get_qtySysAcct().then(
          function(data){
            $scope.params.AgentFee=data.data.SysBalance/100;
          },function(error){

          });
      }
    });


    $scope.doYindaoVisible=function(){
      $scope.visible=true;
    };
  }]);
